using System;

namespace RpgServiceLib.StoryFlagVariable
{
	public class EasyValue
	{
		protected object thisValue {get;set;}
	
		public EasyValue ()
		{
			thisValue = string.Empty;
		}

		public EasyValue (object o)
		{
			SetValue(o);
		}
				
		private bool SetValue(object o)
		{
			if (o is EasyValue)
			{
				thisValue = (o as EasyValue).thisValue;
				return true;
			}
			
			if (o!=null)
			{
				thisValue = o;
				return true;
			}
			return false;
		}
		
		public bool IsValueLongNumber()
		{
			long dummy;
			return long.TryParse(thisValue.ToString(), out dummy);
		}				
		
		public long GetValueAsLongNumber()
		{
			return long.Parse(thisValue.ToString ());
		}

		public bool IsBoolean ()
		{
			bool dummy;
			return bool.TryParse (thisValue.ToString (), out dummy);
		}
		
		public bool GetValueAsBoolean ()
		{
			return bool.Parse (thisValue.ToString ());
		}

		public bool IsString ()
		{
			return thisValue is string;
		}
		
		public string GetValueAsString ()
		{
			return thisValue.ToString();
		}

		public bool IsDecimal ()
		{
			decimal dummy;
			return decimal.TryParse(thisValue.ToString (), out dummy);
		}
		
		public decimal GetValueAsDecimal ()
		{
			return decimal.Parse(thisValue.ToString());
		}

		public bool IsFloatingNumber ()
		{
			double dummy;
			return double.TryParse (thisValue.ToString (), out dummy);
		}
		
		public double GetValueAsFloatingNumber ()
		{
			return double.Parse (thisValue.ToString ());
		}
								
	}
}

